﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TWS.Cart.Business;
using TWS.Cart.Data;

public partial class Application_Cart_Administration_Orders : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
		if (!IsPostBack)
		{
			ViewCartOrderCollection products = new ViewCartOrderCollection().Load();

			GridViewOrders.DataSource = products;
			GridViewOrders.DataBind();
		}
    }

	decimal TotalSalesPrice = 0;

	protected void Grid_OnRowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			ViewCartOrder od = (ViewCartOrder)e.Row.DataItem;

			TotalSalesPrice += od.Total;
		}
		else if (e.Row.RowType == DataControlRowType.Footer)
		{
			e.Row.Cells[3].Text = "Totals:";
			e.Row.Cells[4].Text = String.Format("{0:c}", TotalSalesPrice);
		}
	}
}
